//
//  UIButton+Extension.swift
//  Weibo1.0
//
//  Created by 黄礼潮 on 16/2/16.
//  Copyright © 2016年 黄礼潮. All rights reserved.
//

import UIKit

extension  UIButton {
    
    convenience init(imageName:String ,backImageName:String){
        
    self.init()
 
    setImage(UIImage(named:imageName), forState: .Normal)
    setImage(UIImage(named:imageName + "_highlighted"), forState: .Highlighted)
    setBackgroundImage(UIImage(named:backImageName), forState: .Normal)
    setBackgroundImage(UIImage(named:backImageName + "_highlighted"), forState: .Highlighted)
    
    //根据背景图片大小设置尺寸
    
    sizeToFit()
  
    }
    
    convenience init(title:String,imageName:String,color:UIColor){
    
        self.init()
     
        setTitle(title, forState: .Normal)
        setTitleColor(color, forState: .Normal)
        
        setBackgroundImage(UIImage(named:imageName), forState: .Normal)
  
    }
    
}

 